package com.by.course.controller.course;

import com.by.course.entity.base.BaseResult;
import com.by.course.entity.base.PageResult;
import com.by.course.entity.vo.course.req.*;
import com.by.course.entity.vo.course.resp.BaseCourseResultVO;
import com.by.course.entity.vo.lesson.req.AddBaseLessonVO;
import com.by.course.entity.vo.lesson.req.DeleteBaseLessonVO;
import com.by.course.entity.vo.lesson.req.GetBaseLessonVO;
import com.by.course.entity.vo.lesson.req.UpdateBaseLessonVO;
import com.by.course.entity.vo.lesson.resp.BaseLessonResultVO;
import com.by.course.serivce.BaseCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/course")
@Api(tags = "项目接口")
public class CourseController {

    @Resource
    private BaseCourseService baseCourseService;

    @ApiOperation("项目管理--添加课程")
    @PostMapping("/createCourse")
    public BaseResult<String> createCourse(@RequestBody AddBaseCourseVO vo) {
        return baseCourseService.createCourse(vo);
    }

    @ApiOperation("项目管理--修改课程")
    @PostMapping("/updateCourse")
    public BaseResult<String> updateCourse(@RequestBody UpdateBaseCourseVO vo) {
        return baseCourseService.updateCourse(vo);
    }

    @ApiOperation("项目管理--删除课程")
    @PostMapping("/deleteCourse")
    public BaseResult<String> deleteCourse(@RequestBody DeleteBaseCourseVO vo) {
        return baseCourseService.deleteCourse(vo);
    }

    @ApiOperation("项目管理--通过课程ID查询某个课程")
    @PostMapping("/getCourseById")
    public BaseResult<BaseCourseResultVO> getCourseById(@RequestBody GetBaseCourseVO vo) {
        return baseCourseService.getCourseById(vo);
    }

    @ApiOperation("项目管理--分页查询课程")
    @PostMapping("/queryCourse")
    public BaseResult<PageResult<BaseCourseResultVO>> queryCourse(@RequestBody GetBaseCourseVO vo) {
        return baseCourseService.queryCourses(vo);
    }

    @ApiOperation("章节管理--添加章节")
    @PostMapping("/createLesson")
    public BaseResult<String> createLesson(@RequestBody AddBaseLessonVO vo) {
        return baseCourseService.createLesson(vo);
    }

    @ApiOperation("章节管理--修改章节")
    @PostMapping("/updateLesson")
    public BaseResult<String> updateLesson(@RequestBody UpdateBaseLessonVO vo) {
        return baseCourseService.updateLesson(vo);
    }

    @ApiOperation("章节管理--删除章节")
    @PostMapping("/deleteLesson")
    public BaseResult<String> deleteLesson(@RequestBody DeleteBaseLessonVO vo) {
        return baseCourseService.deleteLesson(vo);
    }

    @ApiOperation("章节管理--查询某个章节")
    @PostMapping("/getLessonById")
    public BaseResult<BaseLessonResultVO> getLessonById(@RequestBody GetBaseLessonVO vo) {
        return baseCourseService.getLessonById(vo);
    }
}
